<?php
namespace app\admin\controller;

use app\admin\model\AuthRule;
use app\common\controller\Base;
use app\common\traits\Gate;
use think\Loader;

class Admin extends Base
{
    /**
     *初始化系统
     */
    protected function _initialize()
    {
        parent::_initialize();
        //session不存在时，不允许直接访问
        if(defined('UID')) return ;
        define('UID',is_login());
        if(!UID)$this->redirect(url('admin/login/login'));
        $auth=new AuthRule;
        $id_curr=$auth->get_url_id();//获取当前菜单的id
//        $id_curr=0;
//        halt($auth->check_auth($id_curr));
        if(!$auth->check_auth($id_curr)) $this->error('权限受限',url('admin/index/index'));
        //获取有权限的菜单tree
        $menus=$auth->get_admin_menus();
        $this->assign('menus',$menus);

        /*获取提醒数据*/
        $this->gettixing();
        $this->assign('controller', Loader::parseName($this->request->controller()));
        $this->assign('module', Loader::parseName($this->request->module()));
    }




}